import 'package:flutter/material.dart';
import 'dart:ui';

class GlassMorphism extends StatefulWidget {
  final double blur;
  final double opacity;
  final Widget child;

  const GlassMorphism(
      {super.key,
      required this.blur,
      required this.opacity,
      required this.child});

  @override
  State<GlassMorphism> createState() => _GlassMorphismState();
}

class _GlassMorphismState extends State<GlassMorphism> {
  @override
  Widget build(BuildContext context) {
    // return widget.child;
    return ClipRRect(
      borderRadius: BorderRadius.circular(12),
      child: BackdropFilter(
        filter: ImageFilter.blur(sigmaX: widget.blur, sigmaY: widget.blur),
        child: Container(
          decoration: BoxDecoration(
            color: Colors.white.withOpacity(widget.opacity),
            borderRadius: const BorderRadius.all(Radius.circular(12)),
            border: Border.all(
              width: 1.5,
              color: Colors.white.withOpacity(0.2)
            )
          ),
          child: widget.child,
        ),
      ),
    );
  }
}
